/**
 *====================================================
* 文件名称: FinanceWriteoffStatementServiceImpl.java
 * 修订记录：
  * No    日期				作者(操作:具体内容)
  * 1.    2016年01月11日	chenxy(创建:创建文件)
  *====================================================
  * 类描述：(说明未实现或其它不应生成javadoc的内容)
  */
package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.common.util.BeanUtils;
import com.yuexunit.finance.project.entity.FinanceWriteoffStatementEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;

/**
 * @ClassName: FinanceWriteoffStatementServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2016年01月11日 16:30:52
 */
@Implements(FinanceWriteoffStatementService.class)
public class FinanceWriteoffStatementServiceImpl implements FinanceWriteoffStatementService {

	@Override
	public Long createFinanceWriteoffStatement(FinanceWriteoffStatementEntity entity) {
		PersistUtil.insert(entity);
		return entity.getWriteoffStatementId();
	}

	@Override
	public void updateFinanceWriteoffStatement(FinanceWriteoffStatementEntity entity) {
		FinanceWriteoffStatementEntity persist = inquireFinanceWriteoffStatement(entity.getWriteoffStatementId());
		BeanUtils.copyProperties(entity, persist);
		PersistUtil.update(persist);
	}

	@Override
	public void renovateFinanceWriteoffStatement(FinanceWriteoffStatementEntity persist) {
		PersistUtil.update(persist);
	}

	@Override
	public FinanceWriteoffStatementEntity inquireFinanceWriteoffStatement(Long writeoffStatementId) {
		return PersistUtil.get(FinanceWriteoffStatementEntity.class, writeoffStatementId);
	}

	@Override
	public List<FinanceWriteoffStatementEntity> inquireFinanceWriteoffStatementList(Long writeoffId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(FinanceWriteoffStatementEntity.class);
		criteria.add(Restrictions.eq("writeoffId", writeoffId));
		return PersistUtil.get(criteria);
	}

	@Override
	public List<FinanceWriteoffStatementEntity> inquireFinanceWriteoffMoneyStatementList(Long moneyStatementId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(FinanceWriteoffStatementEntity.class);
		criteria.add(Restrictions.eq("moneyStatementId", moneyStatementId));
		return PersistUtil.get(criteria);
	}
}
